package model

import (
	"illuminant/config"

	"gitee.com/wangyubin/gutils"
	_ "github.com/go-sql-driver/mysql"
	"github.com/gohouse/gorose/v2"
)

var engin *gorose.Engin

func DB() gorose.IOrm {
	if engin == nil {
		var err error
		var cnf = config.GetConfig()
		engin, err = gorose.Open(&gorose.Config{Driver: "mysql", Dsn: cnf.DB.ConnStr})
		gutils.CheckError(err)
	}

	return engin.NewOrm()
}
